const query = require('../sqlUtil/connect.js')
module.exports = {
    async queryRecords(){
        return query.runSql(`select * from t_records`)
    },
    async addUser(openid){
        return query.runSql(`insert into t_user values('${openid}','微信用户${openid.substring(23)}')`)
    },
    async addRecord(recordsId,openId,detail,address,totalPrice,username){
        return query.runSql(`insert into t_records values('${recordsId}','${openId}','${detail}',NOW(),'${address}','${totalPrice}','${username}')`)
    },
    async queryUser(openid){
        return query.runSql(`select username from t_user where openId='${openid}'`)
    },
    async queryAllRecordsByopenid(openid){
        return query.runSql(`select * from t_records where openId='${openid}'`)
    },
    async checkAccount(account){
        return query.runSql(`select password from t_manager where account='${account}'`)
    },
    async deleteRecordById(recordsId){
        return query.runSql(`delete from t_records where recordsId='${recordsId}'`)
    }
}


